import 'package:aichat_flutter_wallet/module_common/widgets/image/public_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class DAppNoticeComp extends StatefulWidget {
  DAppNoticeComp({
    super.key,
  });

  @override
  _DAppNoticeCompState createState() => _DAppNoticeCompState();
}

class _DAppNoticeCompState extends State<DAppNoticeComp>
    with SingleTickerProviderStateMixin {
  bool isShowAll = false;
  late AnimationController _controller;
  late Animation<double> _rotationAnimation;

  @override
  void initState() {
    super.initState();

    _controller = AnimationController(
      duration: Duration(milliseconds: 300),
      vsync: this,
    );

    // 创建平移动画
    _rotationAnimation = Tween<double>(begin: 1.5 * 3.14159, end: 0.5 * 3.14159)
        .animate(_controller);
    // 创建旋转动画
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return GestureDetector(
        onTap: () {
          setState(() {
            isShowAll = !isShowAll;
            if (_controller.status == AnimationStatus.completed) {
              _controller.reverse();
            } else {
              _controller.forward();
            }
          });
        },
        child: Container(
          margin:
              EdgeInsets.only(left: 20.w, top: 10.w, right: 20.w, bottom: 0),
          padding:
              EdgeInsets.only(left: 15.w, right: 15.w, top: 10.w, bottom: 10.w),
          decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.circular(10.w),
            boxShadow: [
              BoxShadow(
                color: Color.fromRGBO(218, 218, 218, 0.23), // 阴影颜色
                blurRadius: 6.w, // 模糊半径
                spreadRadius: 2.w, // 阴影扩散半径
                offset: Offset(0, 4), // 阴影偏移量
              ),
            ],
          ),
          child: Row(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              PublicImage(
                image: 'assets/images/dapp/tips_logo.png',
                width: 20.w,
                height: 20.w,
              ),
              // SizedBox(
              //   width: 10.w,
              // ),
              // Expanded(
              //     child: Text(
              //   'Due to maintenance,Dapp Browser only supports dapps with BSC Chains,and will gradually restore support for other chains in the next version.',
              //   overflow: isShowAll ? TextOverflow.visible : TextOverflow.ellipsis,
              //   maxLines: isShowAll ? null : 2,
              //   style: TextStyle(
              //     fontSize: 12.sp,
              //     height: 20 / 14,
              //     fontWeight: FontWeight.w400,
              //     color: Color.fromRGBO(51, 51, 51, 1),
              //   ),
              // )),
              SizedBox(
                width: 10.w,
              ),
              AnimatedBuilder(
                animation: _controller,
                builder: (context, child) {
                  return Transform.rotate(
                    angle: _rotationAnimation.value,
                    child: child,
                  );
                },
                child: PublicImage(
                  image: 'assets/images/dapp/history_goback.png',
                  width: 16.w,
                  height: 16.w,
                ),
              )
            ],
          ),
        ));
  }
}
